package com.sky.controller.admin;


import com.sky.result.Result;
import com.sky.service.admin.ShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Api(tags = "店铺操作接口")
@RestController("adminShopController")
@RequestMapping("/admin/shop")
public class ShopController {

    @Autowired
    private ShopService shopService;

    /**
     * 获取营业状态
     * @return
     */
    @ApiOperation("获取营业状态")
    @GetMapping("/status")
    public Result<Long> getStatus(){
        Long status = shopService.getStatus();
        if (status != null ){
            log.info("当前店铺的营业状态为: {}", status == 1 ? "营业中" : "打烊中");
        }else{
            log.info("店铺状态位置无法访问");
        }
        return Result.success(status);
    }


    /**
     * 设置营业状态
     * @param status
     * @return
     */
    @ApiOperation("设置营业状态")
    @PutMapping("/{status}")
    public Result setStatus(@PathVariable Long status){
        shopService.setStatus(status);

        return Result.success();
    }



}
